<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>hello</h1>
    <script src="/socket.io/socket.io.js"></script>
    <script>
        // 连接socket服务
        // 参数：服务器地址
        var socket = io("http://localhost:3000")

        // socket.on 注册事件send，等待触发事件传来数据
        socket.on("send", data => {
            console.log(data)
        })

        // socket.emit 触发事件hehe，传送数据给注册端
        socket.emit("hehe", {name:"hehe"})
    </script>
</body>
</html>